<form action="${ctx}/platManager/manageForm" method="post" id="addPlatManager" enctype="multipart/form-data">
	<input type="hidden" name="userType" value="${userType!}" />
	<input type="hidden" name="id" value="${platManager.id!}" />

	<#if userType == 3 >
		<div class="form-group form-inline row">
			<div class="col-sm-6">
				<#-- 一个人只有一个角色 -->
				<label class="label_role"><span style="color: red" class="label_x">*</span>角色：</label>
				<select class="form-control" name="roleIds" style="width: 120px;" required >
					<option value="">--请选择--</option>
					<#list platRoleList as pr>
                       	<option value="${pr.roleId}" <#if myPlatRoleIdSet?? && myPlatRoleIdSet?seq_contains(pr.roleId)>selected</#if> >${pr.roleName}</option>
                   </#list>
				</select>
			</div>
			<div class="col-sm-6">
				<label><span style="color: red" class="label_x">*</span>部门：</label>
				<select class="form-control" name="groupIds" style="width: 120px;" required >
					<option value="">--请选择--</option>
					<#list platGroupList as pg>
                       	<option value="${pg.groupId}" <#if myPlatGroupIdSet?? && myPlatGroupIdSet?seq_contains(pg.groupId)>selected</#if> >${pg.groupName}</option>
                   </#list>
				</select>
			</div>
		</div>
	</#if>
	<div class="form-group form-inline row">
		<div class="col-sm-6">
			<label class="label_role"><span style="color: red" class="label_x">*</span>名称：</label>
			<input class="form-control" type="text" name="nickName" value="${platManager.nickName!}" maxlength="25" />
		</div>
	</div>
	<div class="form-group form-inline row">
		<div class="col-sm-6">
			<label class="label_loginName"><span style="color: red" class="label_x">*</span>登录名：</label>
			<input class="form-control" type="text" name="loginName" value="${platManager.loginName!}" placeholder="建议使用手机号码" maxlength="25" />
		</div>
	</div>
	<div class="form-group form-inline row">
		<div class="col-sm-6">
			<label><span style="color: red" class="label_x">*</span>联系电话:</label>
			<input class="form-control" type="text" name="phone" value="${platManager.phone!}" maxlength="12" />
		</div>
	</div>
	<!-- <h4 style="padding: 20px 0;border-bottom: 1px solid #e5e5e5">管理员账号：</h4> -->
	<div class="form-group form-inline row">
		<div class="col-sm-6">
			<label class="label-qi">启用状态：</label>
			<#if platManager.state??>
				<label class="radio-inline"><input type="radio" class="minimal" name="state"  value="100" <#if platManager.state = 100>checked</#if> >&nbsp;&nbsp;启用</label>
				<label class="radio-inline"><input type="radio" class="minimal" name="state"  value="200" <#if platManager.state = 200>checked</#if> >&nbsp;&nbsp;禁用</label>
			<#else>
				<label class="radio-inline"><input type="radio" class="minimal" name="state"  value="100" checked >&nbsp;&nbsp;启用</label>
				<label class="radio-inline"><input type="radio" class="minimal" name="state"  value="200" >&nbsp;&nbsp;禁用</label>
			</#if>
		</div>
	</div>
</form>
<script>
	$("#addPlatManager").validate({
        rules: {
        	nickName: {
        		trimRequired: true,
        		unContainSpace: true
            },
        	loginName: {
        		trimRequired: true,
        		unContainSpace: true,
                verifyLoginNameUnique : true
            },
            phone: {
        		trimRequired: true,
        		unContainSpace: true
            }
        },
        messages: {
        	loginName: {
                required: "该字段不能为空"
            }
        }
	});
	
	// 验证输入内容去前后空格后不能为空。返回true验证通过， 返回false验证不通过 
	$.validator.addMethod("trimRequired", function(value, element) {
		if (value == '') {
			return false;
		}
		if ($.trim(value) == '') {
			return false;
		}
		return true;
	}, "该字段不能为空");
	
	// 验证输入内容不包含空格。返回true验证通过， 返回false验证不通过 
	$.validator.addMethod("unContainSpace", function(value, element) {
		if (value == '' || $.trim(value) == '') {
			return true;
		}
		if ($.trim(value).search(/\s/) != -1) {
			return false;
		}
		return true;
	}, "该字段不能包含空格");
	
	// 验证登录名唯一。返回true验证通过， 返回false验证不通过 
	$.validator.addMethod("verifyLoginNameUnique", function(value, element) {
		var id = $(":input[name='id']").val();
		
		var verificationPassed = false;
		$.ajax({
			url : "${ctx}/platManager/verifyLoginNameUnique",
			type : 'post',
			dataType : 'json',
			async : false,
			data : {"id" : id, "loginName" : value},
			success : function(data) {
				if (data.result == 'success') {
					verificationPassed = true;
				}
			}
		});
		
		return verificationPassed;
	}, "登录名不能为重复");

</script>
<style>
	label.label_role {
		padding-left: 27px;
	}
	label.label_loginName {
		padding-left: 13px;
	}
	label{
		margin-right: -30px;
		margin-left: 40px;
	}
	span.label_x {
		display: block;
		height: 20px;
		float: left;
		line-height: 23px;
		padding-right: 3px;
	}
	h4{
		font-weight: 700;
		font-size: 20px;
	}
	label.label-qi {
		margin-left: 49px;
	}
</style>
